//
//  JAGReachability.h
//  JAGatherAdDemo
//
//  Created by Yc on 2022/5/13.
//

#import <Foundation/Foundation.h>
#import <SystemConfiguration/SystemConfiguration.h>
#import <netinet/in.h>

NS_ASSUME_NONNULL_BEGIN

extern NSString *const kJAGReachabilityChangedNotification;

typedef NS_ENUM(NSInteger,JAGNetworkStatus) {
    JAGNotReachable = 0,
    JAGReachableViaWiFi,
    JAGReachableViaWWAN
};

@interface JAGReachability : NSObject

/*!
 * Use to check the reachability of a given host name.
 */
+ (instancetype)reachabilityWithHostName:(NSString *)hostName;

/*!
 * Use to check the reachability of a given IP address.
 */
+ (instancetype)reachabilityWithAddress:(const struct sockaddr *)hostAddress;

/*!
 * Checks whether the default route is available. Should be used by applications that do not connect to a particular host.
 */
+ (instancetype)reachabilityForInternetConnection;


#pragma mark reachabilityForLocalWiFi
//reachabilityForLocalWiFi has been removed from the sample.  See ReadMe.md for more information.
//+ (instancetype)reachabilityForLocalWiFi;

/*!
 * Start listening for reachability notifications on the current run loop.
 */
- (BOOL)startNotifier;
- (void)stopNotifier;

/// 当前网络状态
- (JAGNetworkStatus)currentReachabilityStatus;

/// 当前网络（wifi  5G 4G 3G...）
- (NSString *)currentNetwork;

/*!
 * WWAN may be available, but not active until a connection has been established. WiFi may require a connection for VPN on Demand.
 */
- (BOOL)connectionRequired;

- (NSNumber *)currentReachabilityFlags;

@end

NS_ASSUME_NONNULL_END
